<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Device extends Model
{
    //缺水
    const HYDROPENIA = 2;

    //检修
    const OVERHAUL = 4;

	const REMIND_LIMIT = 5;

    public $fillable = [
    	'code',
        ];

    public function wxUserDevices(){
    	return $this->hasMany('App\Models\WxUserDevice', 'device_id', 'id');
    }

    public function wxUsers(){
    	return $this->belongsToMany('App\Models\WxUser', 'wx_user_devices', 'device_id', 'user_id')->withPivot('remind_times');
    }

    public function userInfos(){
        return $this->belongsToMany('App\Models\UserInfo', 'wx_user_devices', 'device_id', 'user_id');
    }

    public function deviceInfos()
    {
        return $this->hasMany('App\Models\DeviceInfo', 'device_id', 'id');
    }
}
